package demo.web;

import demo.dao.impl.UserMapperImpl;
import demo.pojo.User;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UserAddServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int id= Integer.parseInt(request.getParameter("id"));
        String name=request.getParameter("name");
        String password=request.getParameter("password");
        System.out.println(id);
        System.out.println(name);
        System.out.println(password);
        UserMapperImpl user =new UserMapperImpl();
        if(user.addUser(new User(id,name,password))!=0){
            response.getWriter().print("添加成功");
        }else{
            response.getWriter().print("添加失败");
        }


    }
}
